import {
  request,
  METHOD
} from '@/utils/request'

import axios from 'axios'

import Cookie from 'js-cookie'
const BASE_URL = process.env.VUE_APP_API_URL

/***
 * 教务系统
 */

// 售后-设备返修管理-分页查询设备返修表 1.7.2 WJX
export async function deviceRepairList (params) {
  return request(`${BASE_URL}/todo/admin/deviceRepair/page`, METHOD.GET, params)
}

// 售后-设备返修管理-获取单个设备返修表 1.7.2 WJX
export async function deviceRepairDetail (id) {
  return request(`${BASE_URL}/todo/admin/deviceRepair/detail/${id}`, METHOD.GET)
}

// 售后-设备返修管理-查询设备返修发货单封装对象 1.7.2 WJX
export async function deviceRepairDelivery (params) {
  return request(`${BASE_URL}/todo/admin/deviceRepairDelivery/object`, METHOD.GET, params)
}

// 快递100物流信息查询 1.7.2 WJX
export async function getKuaidi100Detail (params) {
  return request(`${BASE_URL}/business/sysNewDict/getKuaidi100Detail`, METHOD.GET, params)
}

// 售后-设备返修管理-设备号返修审核 1.7.2 WJX
export async function deviceRepairUpdate (id, params) {
  return request(`${BASE_URL}/todo/admin/deviceRepair/update/${id}`, METHOD.PUT, params)
}

// 售后-设备返修管理-设备返修收货确认(商户发货) 1.7.2 WJX
export async function receiptConfirm (params) {
  return request(`${BASE_URL}/todo/admin/deviceRepairDelivery/receiptConfirm`, METHOD.POST, params)
}

// 售后-设备返修管理-设备返修发货单图片上传 1.7.2 WJX
export function deviceRepairDeliveryUploadImage () {
  return `${BASE_URL}/todo/admin/deviceRepairDelivery/uploadImage`
}

// 售后-设备返修管理-设备返修返厂物流上传(设备返修返厂物流) 1.7.2 WJX
export async function deviceRepairDeliveryReturnFactory (params) {
  return request(`${BASE_URL}/todo/admin/deviceRepairDelivery/returnFactory`, METHOD.POST, params)
}

// 售后-设备返修管理-结束返修单 1.7.2 WJX
export async function deviceRepairTerminate (params) {
  return request(`${BASE_URL}/todo/admin/deviceRepair/terminate`, METHOD.POST, params)
}

// 售后-设备返修管理-返厂收货 1.7.2 WJX
export async function returnFactoryReceive (params) {
  return request(`${BASE_URL}/todo/admin/deviceRepairDelivery/returnFactoryReceive`, METHOD.POST, params)
}

// 售后-设备返修管理-设备返修完成发给商户 1.7.2 WJX
export async function backToMerchant (params) {
  return request(`${BASE_URL}/todo/admin/deviceRepairDelivery/backToMerchant`, METHOD.POST, params)
}

// WYJ 根据数据类型名称查询
export async function listByName (params) {
  return request(`${BASE_URL}/business/admin/base/data/dict/listByName`, METHOD.GET, params)
}

//   YXB 售后-离线数据-分页查询
export async function offlineDataList (params) {
  return request(`${BASE_URL}/business/iotadmin/afterSale/offlineDataList`, METHOD.GET, params)
}
// 添加学生信息
export async function addStudent (params) {
  return request(`${BASE_URL}/students/addStudent
  `, METHOD.POST, params)
}
// 更新学生信息
export async function editStudent (params) {
  return request(`${BASE_URL}/students/updateStudent
  `, METHOD.POST, params)
}
// 数据字典
export async function typeList (params) {
  return request(`${BASE_URL}/Properties/listProperties`, METHOD.POST, params)
}
export const imageAccept = 'image/jpeg,image/png'
export const docAccept = '.doc,.docx,.pdf,.xls,.xlsx'
//  文件上传
export async function failExport (params) {
  // alert(data)
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    url: `${BASE_URL}/files/upload`,
    responseType: 'blob',
    params
  })
}
// 上传图片、文件
export function uploadImg () {
  return `${BASE_URL}/files/upload`
}
// 下载模板
export async function getTemplateDownload () {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    url: `${BASE_URL}/files/template/template.xlsx`,
    responseType: 'blob'
  })
}
// 批量导入
export async function batchImportant (data) {
  return request(`${BASE_URL}/files/batchAddStudents`, METHOD.POST, data)
}
// 学生列表
export async function listStudents (data) {
  return request(`${BASE_URL}/students/listStudents`, METHOD.POST, data)
}
// 导出学生名单
export async function StudentsDownload (data) {
  return request(`${BASE_URL}/students/downloadStudents`, METHOD.POST, data)
}
